Repository navigation
Conversation
disktree already builds and draws on macOS through GPUI's Metal backend;
what did not carry over was the Linux plumbing underneath.
- Mount table from getfsstat(2) with MNT_NOWAIT instead of
/proc/self/mounts, so foreign mounts (SMB/NFS shares, simulator
images, /dev, the other APFS system volumes) are left out by path
again and a dead network share cannot stall a scan.
- Firmlinks: the volume a path lives on comes from statfs(2), so /Users
resolves to the Data volume. --disk scans / and skips
/System/Volumes/Data, counting the sealed system and every user file
once.
- Move to trash uses NSFileManager, the Finder's Trash with Put Back,
instead of falling through to ~/.local/share/Trash.
- Free space includes purgeable space (the Finder's figure).
- System trees gain /System, /Library, /private/{etc,var/db,var/vm} and
/opt/homebrew, judged through either face of a firmlink.
- CI runs lint and tests on macos-15 as well.
The macOS code lives in disktree-core/src/macos.rs. getfsstat is the
one unsafe call, with a documented allow; libc and objc2 are already in
the graph through GPUI, so no crates are added.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
How this compares with #1, #3 and #7
Four macOS PRs came in within about six hours, and I should have checked before I opened this one. To save you some review time, here is a side-by-side comparison. I made it by reading all four diffs. I have not run the other branches. Note that #7 is built on #1's two commits (b6c1b11, dbca8b2), so #7 includes all of #1.
One safety point worth a look whichever PR you takeOn macOS, Where #8 is weaker
What only #8 adds
If #3 or #7 is the direction you want, I'm happy to rebase the purgeable-space change onto whichever one lands, as a small follow-up. |
Guards that the first macOS pass left out, found while comparing with the other macOS PRs: - A parent of the home directory is refused. /Users is not a mount point on macOS (and /home need not be one on Linux), so the mount guard did not catch it, and remove_dir_all would empty the home directory before failing on the root-owned parent. - A parent of a system tree is refused (/var holds /var/lib; /opt holds /opt/homebrew on macOS). - Before each removal, the worker checks the mount table for a filesystem mounted inside the target; remove_dir_all does not stop at mount points. - Guards compare without case on macOS, where the default APFS volume is case-insensitive. - Mounts get their second spelling through /usr/share/firmlinks, so a share at /Volumes/NAS is also left out at /System/Volumes/Data/Volumes/NAS when a scan starts on the Data volume. - The macOS system-tree list is compiled only on macOS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
disktree already builds and draws on macOS through GPUI's Metal backend. What did not carry over was the Linux plumbing underneath. On macOS today:
~/.local/share/Trash, where the Finder never looks;/proc/self/mountsdoes not exist, so--diskscans/with no mount table. The device fallback has to open each directory, so it can wake a mounted network share;This PR fixes these in
disktree-core, and it does not touch the UI crate:getfsstat(2)andMNT_NOWAIT, so a dead SMB/NFS share cannot stall a scan and is never entered.statfs(2)gives the real volume of a path, so/Usersresolves to the Data volume.--diskscans/and skips/System/Volumes/Data, so the sealed system and every user file are each counted once.NSFileManager, so items go to the Finder's Trash and Put Back works./System,/Library,/private/{etc,var/db,var/vm}and/opt/homebrewon macOS, judged through both faces of a firmlink and without case (the default APFS volume is case-insensitive)./usr/share/firmlinks, so a share at/Volumes/NASis also left out at/System/Volumes/Data/Volumes/NAS./Usersis not a mount point on macOS, and/homeneed not be one on Linux, so without this checkremove_dir_allwould empty the home directory before it failed on the root-owned parent. A parent of a system tree is refused too (/varholds/var/lib). Before each removal, the worker checks the mount table for a filesystem mounted inside the target, becauseremove_dir_alldoes not stop at mount points.macos-15job with the same lint and test steps.All macOS code is in
disktree-core/src/macos.rsor behindcfg(target_os = "macos").getfsstatis the oneunsafecall, with a documentedallow.libcandobjc2are already in the graph through GPUI, so the change adds no crates (theCargo.lockdiff is 3 lines).Tested
cargo xtask lintandcargo xtask teston Linux and macOS in CI, and locally on 1.97 and 1.98.whole_disk_smokeon a 460 GB Mac: 333 GiB in 37 s. It left out 13 foreign mounts (NAS shares, simulator images, the other APFS system volumes), with no double counting.--diskscan, marked/Users: the review screen keeps it back ("it contains the home directory") and acts on 0 items.Not in this PR
make installstill writes a Linux desktop entry on macOS. A.appbundle and a macOS release build (DMG and tarball) can be a follow-up PR if you want them.🤖 Generated with Claude Code